package util;

import java.util.TreeMap;

public class Tex {
    
    // Singleton for this class
    private static Tex loader;
    
    public static Tex loader() { // Singleton getter
        if (loader == null) {
            loader = new Tex();
        }
        return loader;
    }
    
    private TreeMap<String, Bitmap> nameMap;
    private Bitmap defaultTex;
    private int numTextures;
    
    private Tex() {
        nameMap = new TreeMap<String, Bitmap>();
        defaultTex = new Bitmap(1, 1, new int[] { Color.MAGENTA });
        numTextures = 0;
    }
    
    public void load(String texName) {
        if (!nameMap.containsKey(texName)) {
            Bitmap tex = new Bitmap(texName);
            nameMap.put(texName, tex);
            numTextures++;
        }
    }
    
    public Bitmap get(String texName) {
        if (nameMap.containsKey(texName)) {
            return nameMap.get(texName);
        } else {
            return defaultTex;
        }
    }
    
}
